#define  _CRT_SECURE_NO_WARNINGS 1	
#include <stdio.h>
#include <string.h>
int main() {
    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; i++)
    {
        char arr[101];
        scanf("%s", arr);
        int low = 0, high = 0, digit = 0, other = 0;
        if (arr[0] >= '0' && arr[0] <= '9')
        {
            printf("NO\n");
            continue;
        }
        if (strlen(arr) < 8)
        {
            printf("NO\n");
            continue;
        }
        for (int i = 0; i < strlen(arr); i++)
        {
            if (arr[i] >= 'a' && arr[i <= 'z'])
                low++;
            else if (arr[i] >= 'A' && arr[i <= 'Z'])
                high++;
            else  if (arr[i] >= '0' && arr[i] <= '9')
                digit++;
            else
                other++;
        }
        if (other != 0)
        {
            printf("NO\n");
            continue;
        }
        if ((low > 0) + (high > 0) + (digit > 0) >= 2)
        {
            printf("YES\n");
        }
        else {
            printf("NO\n");
        }
    }


    return 0;
}